//第13天
package  main

import (
	"fmt"
)

//不定参数本质是slice
func hell(num ...int){
	num[0] = 18
	num[1] = 20
}

func test1(num int) {
	fmt.Printf("%b \n", num)
}

func test2() int{
	//将手牌转化成整数形式
	cards := []int{11,12}
	//我是升序排的，所以反着来
	res := 0
	for i := len(cards) - 1; i >= 0; i-- {
		res *= 10
		res += cards[i]
	}
	fmt.Println("__test2__", res)
	return res

}

func main() {

	test1(0)
	test1(1)
	test1(3)
	test1(6)
	test1(9)
	suitShift := []int{0,3,6,9}
	flush := 0
	flush += 1 << uint(suitShift[1])
	flush += 1 << uint(suitShift[1])

	straight := []int{0, 0, 0, 0}
	straight[0] |= 1 << uint(1) //与 得到指定花色的牌
	straight[0] |= 1 << uint(2) //与

	straight[0] |= 1
	for k, v := range straight {
		fmt.Printf("straight %v, %b \n", k, v)
	}

	fmt.Printf("flush__%b \n", flush)

	test2()

	//切片与数组
	s1 := []int{1, 2, 3}
	s2 := s1[1:] // -> s1{2,3}
	s2[1] = 4 // -> s2[2,4]
	fmt.Println(s1)
	s2 = append(s2, 5, 6, 7) // -> s2[2,4,5,6,7]
	fmt.Println(s2)

	//代码块作用域
	a := 3
	if a := 1; false {

	} else if b := 2; false {

	} else {
		println(a, b)
	}

	fmt.Println(a)

}


